﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace TrabalhoSeven.Estados.Jogo {
	class Fundo {
		Texture2D texture;
		Rectangle origem;
		Rectangle destino;
		GameWindow Window;

		public Fundo(Texture2D texture, GameWindow Window) {
			this.texture = texture;
			this.Window = Window;

			destino = new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height);

			origem = new Rectangle(0, texture.Height - Window.ClientBounds.Height, Window.ClientBounds.Width, Window.ClientBounds.Height);

		}

		public void Update(GameTime gameTime, Vector2 posicao, bool direita) {
			if (direita == true) {
				if (origem.X > Window.ClientBounds.Width) {
					return;
				}
				origem.X += (int)(posicao.X);
				origem.Y += (int)(posicao.Y);
			}
			else {
				if (origem.X < 0) {
					return;
				}
				origem.X -= (int)(posicao.X);
				origem.Y -= (int)(posicao.Y);
			}

		}

		public void Draw(GameTime gameTime, SpriteBatch spriteBatch) {
			spriteBatch.Draw(texture, destino, origem, Color.White);
		}
	}
}
